<template>
  <div class="m-login-container">
    <el-row class="m-main-header-search" justify="space-between">
      <el-button
        @click="handleOpareteClick(1)"
        type="primary"
        size="small"
        icon="el-icon-circle-plus-outline"
      >
        新增
      </el-button>
    </el-row>
    <div class="m-main-content-body">
      <p class="contant-body-title">用户</p>
       <el-table
      v-loading="loading"
      ref="multipleTable"
      :data="list"
      tooltip-effect="dark"
      style="width: 100%"
      stripe
      :header-cell-style="{
        'background-color': '#E5EEFF',
      }"
    >
      <el-table-column
        prop="user_name"
        label="登录名"
        :autoFit="true"
        :fitHeader="true"
      >
      </el-table-column>
      <el-table-column
        prop="real_name"
        label="姓名"
        :autoFit="true"
        :fitHeader="true"
      ></el-table-column>
      <el-table-column
        prop="phone"
        label="联系电话"
        :autoFit="true"
        :fitHeader="true"
      ></el-table-column>
      <el-table-column
        prop="email"
        label="邮箱"
        :autoFit="true"
        :fitHeader="true"
      ></el-table-column>
      <el-table-column
        prop="time"
        label="创建时间"
        :autoFit="true"
        :fitHeader="true"
      >
        <template slot-scope="scope">
          {{
            scope.row.time
              ? $moment(scope.row.time).format("YYYY/MM/DD HH:mm:ss")
              : "--"
          }}
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作"
        :autoFit="true"
        :fitHeader="true"
      >
        <template slot-scope="scope">
          <span>
            <el-button
              @click="handleOpareteClick(2, scope.row)"
              type="text"
              size="small"
            >
              编辑
            </el-button>
          </span>
        </template>
      </el-table-column>
    </el-table>
    </div>

    <dialog-set
      v-if="dislogSetVisible"
      @close="dislogSetVisible = false"
      :info="tempInfo"
      @getList="getList"
    ></dialog-set>
  </div>
</template>

<script>
import DialogSet from "./components/DialogSet";
export default {
  components: {
    DialogSet,
  },
  data() {
    return {
      list: [],
      loading: false,
      dislogSetVisible: false,
      tempInfo: {},
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    /*
     * @Desc: 获取列表
     * @params: {String}
     * @return: {Object}
     */
    async getList() {
      this.loading = true;
      const { data } = await this.$api.user.getList();
      this.__globalHandleResponseMixin(data, () => {
        this.list = data.data;
      });
      this.loading = false;
    },

    /*
     * @Desc: 编辑
     * @params: {String}
     * @return: {Object}
     */
    async handleOpareteClick(type, row = {}) {
      this.tempInfo = {
        type,
        ...row,
      };
      this.dislogSetVisible = true;
    },
  },
};
</script>

<style lang="less" scoped></style>
